package com.cy.pj.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;

/*封装服务端响应到客户端的数据，此对象定义规范化格式*/
@Data
@NoArgsConstructor//这个类有带参的加个无参的
public class JsonResult implements Serializable {
    private static final long serialVersionUID = -4971076199594828397L;

    private Integer state=123;//状态：ok，0，error

    private String message="ok";//状态信息

    private Object data;//业务层返回的正确响应数据

    public JsonResult(String message){ //new JsonResult("updata ok");
        this.message=message;
    }
    public JsonResult(Object data){
        this.data=data;
    }
    public JsonResult(Throwable e){
        this.state=0;
        this.message=e.getMessage();
    }
}
